﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ShowLocationsAndFramesAlwaysonTop.CUiAOTShowLocationsAndFramesAlwaysOnTopCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.ShowLocationsAndFramesAlwaysonTop;

public class CUiAOTShowLocationsAndFramesAlwaysOnTopCmd : TxToggleButtonCommand
{
  private bool m_toggled;

  private bool IsToggled
  {
    get => this.m_toggled;
    set => this.m_toggled = value;
  }

  public virtual bool Push => this.IsToggled;

  public virtual string Category => AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_CATAGORY;

  public virtual string Tooltip => AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_TOOLTIP;

  public virtual string Description => AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_DESCRIPTION;

  public virtual void Execute(object cmdParams)
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    try
    {
      this.Toggle();
      TxDocumentEx txDocumentEx = new TxDocumentEx();
      TxApplication.ActiveUndoManager.ClearAllTransactions();
      txDocumentEx.ChangeLocationAndFramesAlwaysOnTopState(this.IsToggled);
    }
    catch (TxException ex)
    {
      int num = (int) TxMessageBox.Show(AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_FAILED, AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_NAME, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
    finally
    {
      TxApplication.RefreshDisplay();
      TxApplication.ActiveUndoManager.ClearAllTransactions();
      Cursor.Current = current;
    }
  }

  private void Toggle() => this.IsToggled = !this.IsToggled;

  public virtual string Name => AOTStringTable.AOT_LOCATIONS_AND_FRAMES_CMD_NAME;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("LocationsOnTop");
}
